//
//  ColorMacro.swift
//  invest_account_books
//
//  Created by volientDuan on 2017/11/17.
//  Copyright © 2017年 volient. All rights reserved.
//

import UIKit
let WHITE_COLOR = "#FFFFFF"

// MARK: - 常用RGB16进制值

let ThemeColor = RGB("#57c0ff")

let ViewBGColor = RGB("#fefefe")
let TextNormalColor = RGB("#8a8a8a")
let TextSelectedColor = ThemeColor


/// 16进制String值转UIColor
///
/// - Parameter hex: 16进制String值:#xxxxxx
/// - Returns: UIColor
func RGB(_ hex: String) -> UIColor {
    var red:UInt32 = 0, green:UInt32 = 0, blue:UInt32 = 0
    var cString : String;
    if hex.hasPrefix("#") {
        let index   = hex.index(hex.startIndex, offsetBy: 1)
        cString = String(hex.suffix(from: index))
        let rIndex = cString.index(cString.startIndex, offsetBy: 2)
        let rString = String(cString.prefix(upTo: rIndex))
        cString = String(cString.suffix(from: rIndex));
        let gIndex = cString.index(cString.startIndex, offsetBy: 2)
        let gString = String(cString.prefix(upTo: gIndex))
        let bString = String(cString.suffix(from: gIndex))
        Scanner(string: rString).scanHexInt32(&red)
        Scanner(string: gString).scanHexInt32(&green)
        Scanner(string: bString).scanHexInt32(&blue)
    }
    return UIColor.init(red: CGFloat(red)/255.0, green: CGFloat(green)/255.0, blue: CGFloat(blue)/255.0, alpha: 1.0)
}

class ColorMacro: NSObject {

}
